//
//  NSString+DP.m
//  weibo
//
//  Created by DP on 16/7/6.
//  Copyright © 2016年 DP. All rights reserved.
//

#import "NSString+DP.h"

@implementation NSString (DP)
+ (NSDate *)SrtingToDate:(NSString *)str {
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat: @"EEE MMM dd HH:mm:ss zzz yyyy"];
    return [formatter dateFromString:str];
}
/**
 根据字符串获取具体年月日，时分秒
 */
+ (NSDateComponents*)timeWithString:(NSString *)str {
    NSCalendar *canlender = [NSCalendar currentCalendar];
    NSCalendarUnit type = NSCalendarUnitEra | NSCalendarUnitYear| NSCalendarUnitMonth| NSCalendarUnitDay| NSCalendarUnitWeekday | NSCalendarUnitWeekdayOrdinal|NSCalendarUnitQuarter |NSCalendarUnitWeekOfMonth | NSCalendarUnitWeekOfYear| NSCalendarUnitYearForWeekOfYear |  NSCalendarUnitNanosecond | NSCalendarUnitCalendar | NSCalendarUnitTimeZone;
    NSDateComponents *compt = [canlender components:type fromDate:[self SrtingToDate:str]];
    return compt;
}

@end
